
/*
 * ReportUpdateServlet.java
 *
 * Created on 1 December, 2007, 5:18 PM
 */

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.net.*;

import dbmanager.*;
import utility.MasterPLOperations;
/**
 *
 * @author Hemant
 * @version POOLWeb 0.0.1
 * This servlet is dedicated for handling property delete requests.
 */
public class DeleteServlet extends HttpServlet 
{   
    /**
	 * 
	 */
	private static final long serialVersionUID = 6517871976072437262L;
	String property,property_value,master;
    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /** Handles the HTTP <code>GET</code> method.
     * @param request servlet request
     * @param response servlet response
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException 
    {
    	// Get session object
        HttpSession session = request.getSession(true);
        System.out.println("I'm in report delete servlet");
        String username = (String)session.getAttribute("username");
        String password = (String)session.getAttribute("password");
        
        String temp = URLDecoder.decode(request.getParameter("linkclicked"),"UTF-8");
        System.out.println("The link clicked is    "+temp);
        
        GetIdName get = new GetIdName();
        
        try
        {
            String master = temp.split("\t")[0];
            String property = temp.split("\t")[1];
            String value = temp.split("\t")[2];
            String ref = temp.split("\t")[3];
            
            System.out.println("master "+master);
            System.out.println("property "+property);
            System.out.println("value "+value);
            System.out.println("ref "+ref);
            
            /*Hashtable<Object,Object> hash = new Hashtable<Object,Object>();
            hash.put("mid",master);
            hash.put("pid",property);
            hash.put("pv",property_value);  
            
            retail.bean.property_detailsBean prop = new retail.bean.property_detailsBean();
            prop.setDBManager(db);
            prop.setProcess("del");
            prop.setNewPropertyHash(hash);
            prop.deleteProperty();*/
            
            MasterPLOperations masterpl = new MasterPLOperations(username, password);
            masterpl.setremoveProperty(master, property, value, ref);
            masterpl.removeProperty();
            response.sendRedirect("ResponseServlet");
        }
        catch(ArrayIndexOutOfBoundsException e)
        {
            e.printStackTrace();
        }
        catch(Exception e1)
        {
            e1.printStackTrace();
        }
        finally
        {
        	get = null;
        }
    }
    
    /** Handles the HTTP <code>POST</code> method.
     * @param request servlet request
     * @param response servlet response
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException 
    {
        doGet(request,response);
    }
    
}
